package com.example.jwtjava.exception;

import com.example.jwtjava.common.R;
import io.jsonwebtoken.ExpiredJwtException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @Author 宋伟宁
 * @Date 2023/10/23
 * @Version 1.0
 **/
@RestControllerAdvice
public class GlobaException {

    @ExceptionHandler(NullPointerException.class)
    public R handlerException(NullPointerException e){
        return new R(300,false,"空指针异常");
    }

    @ExceptionHandler(ServiceException.class)
    public R handlerServiceException(NullPointerException e){
        return new R(401,false,"token失效");
    }

    @ExceptionHandler(ExpiredJwtException.class)
    public R handlerException(ExpiredJwtException e){
         return  new R(401,false,"token失效");
    }

}
